package com.example.springbootlinmtest.test;

import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Linm
 * @Date 2023/8/14 19:01
 */
public class forNanan {
    public static void main(String[] args) {
        //String str = "二年级-52721152-航瑞;二年级-6845102-家蔚;嘉嘉;梦梦妈妈;明天100个月-2278494-孟德远;三年级-44312402-谢一诺;三年级-恩典-3035786;三年级53313280睿睿;四-7-7147473-陈梓畅;四年级112个月-23891218-小白;small luobo;外婆107个月-28448235-李承泽;下午看112个月-12776278-涛涛;有时间99个月-41923376-乐乐;周六看100个月-4926790-嘟嘟;周六做11020363三年级核桃;周末完109个月-34015258-乐乐;周五100个月-19668654-秦骄;姑娘叫大莲;（买）113个月-5033260-周正;100个月-11155760-李一菲;100个月-11937633-西子;100个月-18997461-妙妙;100个月-22877187-诺诺;100个月-52861594-朗朗;100个月-601087-小语;100个月-7163944-刘歆奕;100个月-7257500-百川;101个月-10509552-林义洋;101个月-10849601-金宝;102个月-27504052-大宝;103个月-11012126-揭贽文;103个月-169603-杜斌豪;103个月-53082584-小茂;104个月-22024899-俊宝;104个月-33713791-元宝;104个月-46437814-妍晨;104个月-7157481-柑橘;105个月-394798-城城;106个月-12855732-灿灿;106个月-2180422-诗宝;106个月-27584427-隽端;106个月-322657-聪聪;106个月-8070785-美丽;106个月-9990943-铭铭;107个月-53044004-学习中的左左;107个月-53471414-王佳生;107个月-5691519-皮钰琴;107个月-584776-果果;108个月-18939410-王晨宇;108个月-2997186-单单;108个月-53027253-胡蝶;108个月-9575551-游游;109个月-52727475-PETER;109个月-8289906-马志;109个月-9812198-忧忧;110个月-33736238-倩倩;110个月-8829052-杨子晴;111个月-1408232-芯芯宝贝;111个月-1492479-菲菲;111个月-2084274-俊卿;111个月-21942699-铃铛;111个月-27214438-澳棋;111个月-3350953-石头;111个月-5432653-阳阳;112个月-31774734-贾培;112个月-3194434-枨枨;118个月-45696769-赫赫;119个月-52999550马钰涵;49909786-敖祥-四年级;53613583赫苒;8点半10个月-8067118-刘佳恩;90个月-43766999-译译;90个月-6058136-荣荣;95个月-37607466-项楚珺;95个月-5597007-灵玲;97个月-25770531-安安李毅豪;97个月-31568736-乖乖;98个月-19331788-宣萱;98个月-21093743-文文;98个月-3180729-兜兜;99个月-44833539-乐乐;99个月-4746247-佳佳;9岁三年级-53154996-戈馨源;";
        String filePath = "D:\\Users\\Desktop\\input.txt";
        String str = null;
        try {
            str = new String(Files.readAllBytes(Paths.get(filePath)));
            //System.out.println(str);
        } catch (IOException e) {
            e.printStackTrace();
        }

        List<String> list = Arrays.asList(str.split(";"));
        System.out.println("======"+list.size());
       // System.out.println(list.toString());
        List<String> result = new ArrayList<>();
        for (String lists:list) {
            String[] tmpStr = null;
            try{
                Pattern pattern = Pattern.compile("\\d+");
                Matcher matcher = pattern.matcher(lists);
                while (matcher.find()) {
                    if (matcher.group().length()<4){
                        //System.out.println("不输出=="+matcher.group());
                    }else{
                       // System.out.println(matcher.group());
                        result.add(matcher.group());
                    }
                }
                //System.out.println(tmpStr[1]);
            }catch (Exception e){
                System.out.println(lists+"==不能分割");
            }
        }
        System.out.println("数据长度=="+result.size());
        try (PrintWriter writer = new PrintWriter("D:\\Users\\Desktop\\output.txt", "UTF-8")) {
            for (String strpp : result) {
                writer.println(strpp);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
